package event;

import observer.ObservedString;

/**
 * This is for events in which an {@link ObservedString} changes value.
 *
 * @author Neil Dickson
 */
public class StringChangeEvent implements Undoable {
	private	ObservedString	string;
	private	String			oldValue;

	public StringChangeEvent(ObservedString string,String oldValue) {
		this.string = string;
		this.oldValue = oldValue;
	}

	public Undoable undo() {
		String newOldValue = string.toString();
		string.setValue(oldValue);
		// FIXME: Move the view to the location of the changed ObservedString.
		return new StringChangeEvent(string,newOldValue);
	}

	public String getDescription() {
		return "Changing "+oldValue+" to "+string;
	}

	public ObservedString getString() {
		return string;
	}

	public String getOldValue() {
		return oldValue;
	}
}
